import Vue from 'vue'
import Router from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(Router)

export const constantRouterMap = [
    {
        path: '/',
        name: 'home',
        component: Home,
    },
    //注册模块
    {path: '/registered/GL', name: '/registered/GL', component: () => import('../views/web/registered/GL')},
    {path: '/registered/JG', name: '/registered/JG', component: () => import('../views/web/registered/JG')},
    {path: '/registered/JL', name: '/registered/JL', component: () => import('../views/web/registered/JL')},
    {path: '/registered/QY', name: '/registered/QY', component: () => import('../views/web/registered/QY')},

    //登录
    {path: '/login/login', name: '/login/login', component: () => import('../views/web/login/login')},

    // 教案
    {path: '/coach/mycourse', name: '/coach/mycourse', component: () => import('../views/coach/mycourse')},

    // 教案详情
    {path: '/coachTraining/lessonDetail', name: '/aboutUs', component: () => import('../views/coach/lessonDetail')},


    //WEB模块
    {
        path: '/coachTraining',
        name: '/coachTraining',
        component: () => import('../views/web/coachTraining'),
    },
    {
        path: '/trainingAgency',
        name: '/trainingAgency',
        component: () => import('../views/web/trainingAgency'),
    },
    {
        path: '/aboutUs',
        name: '/aboutUs',
        component: () => import('../views/web/aboutUs')
    },
    {
        path: '/information',
        name: '/information',
        component: () => import('../views/web/information')
    },
    {
        path: '/informationDetails/:id',
        name: '/informationDetails',
        component: () => import('../views/web/informationDetails')
    },
    {
        path: '/trainingDetail',
        name: '/trainingDetail',
        component: () => import('../views/web/trainingDetail')
    }, {
        path: '/trainingDetailtoll',
        name: '/trainingDetailtoll',
        component: () => import('../views/web/trainingDetailtoll'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/youthInstituttons',
        name: '/youthInstituttons',
        component: () => import('../views/web/youthInstituttons')
    },
    {
        path: '/instituttonsDetails/:id',
        name: '/instituttonsDetails',
        component: () => import('../views/web/instituttonsDetails')
    },
    {
        path: '/familyTeenagers',
        name: '/familyTeenagers', component: () => import('../views/web/familyTeenagers')
    },
    {
        path: '/familyTeenagersDetail',
        name: '/familyTeenagersDetail',
        component: () => import('../views/web/familyTeenagersDetail')
    },
    {
        path: '/familyTeenagersEdit',
        name: '/familyTeenagersEdit',
        component: () => import('../views/web/familyTeenagersEdit'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/myPost',
        name: '/myPost',
        component: () => import('../views/web/myPost'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/post',
        name: '/post',
        component: () => import('../views/web/post')
    },
    {
        path: '/eventInformation',
        name: '/eventInformation',
        component: () => import('../views/web/eventInformation')
    },
    {
        path: '/eventInformationDetails/:id',
        name: '/eventInformationDetails',
        component: () => import('../views/web/eventInformationDetails')
    },
    {
        path: '/tournamentRegistration',
        name: '/tournamentRegistration',
        component: () => import('../views/web/tournamentRegistration')
    },
    {path: '/starsSettled', name: '/starsSettled', component: () => import('../views/web/starsSettled')},
    {
        path: '/businessCooperation',
        name: '/businessCooperation',
        component: () => import('../views/web/businessCooperation')
    },

    //家长/球员模块
    {
        path: '/parent/coachDetail',
        name: '/parent/coachDetail',
        component: () => import('../views/parent/coachDetail'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/parent/editor',
        name: '/parent/editor',
        component: () => import('../views/parent/editor'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/parent/index',
        name: '/parent/index',
        component: () => import('../views/parent/index'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/parent/parentsCoachDetail',
        name: '/parent/parentsCoachDetail',
        component: () => import('../views/parent/parentsCoachDetail'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/parent/uploadVideo',
        name: '/parent/uploadVideo',
        component: () => import('../views/parent/uploadVideo'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/parent/onlingInflation',
        name: '/parent/onlingInflation',
        component: () => import('../views/web/onlingInflation')
    },
    {
        path: '/parent/lessonDetail',
        name: '/parent/lessonDetail',
        component: () => import('../views/parent/lessonDetail')
    },
    {
        path: '/parent/onlingInflationDetails',
        name: '/parent/onlingInflationDetails',
        component: () => import('../views/web/onlingInflationDetails')
    },
    {
        path: '/parent/onlingInflationDetailstoll',
        name: '/parent/onlingInflationDetailstoll',
        component: () => import('../views/web/onlingInflationDetailstoll'),
        meta: {
            requiresAuth: true
        }
    },
    //教练模块
    {
        path: '/coach/auditDetail',
        name: '/coach/auditDetail',
        component: () => import('../views/coach/auditDetail'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/coach/courseDetail',
        name: '/coach/courseDetail',
        component: () => import('../views/coach/courseDetail'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/coach/index',
        name: '/coach/index',
        component: () => import('../views/coach/index'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/coach/myDate',
        name: '/coach/myDate',
        component: () => import('../views/coach/myDate'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/coach/myDateEdit',
        name: '/coach/myDateEdit',
        component: () => import('../views/coach/myDateEdit'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/coach/groupMan',
        name: '/coach/groupMan',
        component: () => import('../views/coach/groupMan'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/coach/auditList',
        name: '/coach/auditList',
        component: () => import('../views/coach/auditList'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/coach/lessonDetail',
        name: '/coach/lessonDetail',
        component: () => import('../views/coach/lessonDetail'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/coach/editorLesson',
        name: '/coach/editorLesson',
        component: () => import('../views/coach/editorLesson'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/coach/teamdetail',
        name: '/coach/teamdetail',
        component: () => import('../views/coach/teamdetail'),
        meta: {
            requiresAuth: true
        }
    },
    // 机构管理
    // 机构管理
    {
        path: '/organ/index',
        name: '/organ/index',
        component: () => import('../views/organ/index'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/organ/auditDetail',
        name: '/organ/auditDetail',
        component: () => import('../views/organ/auditDetail'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/organ/coachDetail',
        name: '/organ/coachDetail',
        component: () => import('../views/organ/coachDetail'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/organ/equipApply',
        name: '/organ/equipApply',
        component: () => import('../views/organ/equipApply'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/organ/myIntrodu',
        name: '/organ/myIntrodu',
        component: () => import('../views/organ/myIntrodu'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/organ/organList',
        name: '/organ/organList',
        component: () => import('../views/organ/organList'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/organ/set',
        name: '/organ/set',
        component: () => import('../views/organ/set'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/organ/edit',
        name: '/organ/edit',
        component: () => import('../views/organ/WoDeJianJieEdit'),
        meta: {
            requiresAuth: true
        }
    },

    // 机构管理
    // 机构管理
    {
        path: '/platform/index',
        name: '/platform/index',
        component: () => import('../views/platform/index'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/edit',
        name: '/platform/edit',
        component: () => import('../views/platform/edit'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/listing',
        name: '/platform/listing',
        component: () => import('../views/platform/listing'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/listingdetail',
        name: '/platform/listingdetail',
        component: () => import('../views/platform/listingdetail'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/finance',
        name: '/platform/finance',
        component: () => import('../views/platform/finance'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/curriculum',
        name: '/platform/curriculum',
        component: () => import('../views/platform/curriculum'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/curriculumEdit',
        name: '/platform/curriculumEdit',
        component: () => import('../views/platform/curriculumEdit'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/training',
        name: '/platform/training',
        component: () => import('../views/platform/training'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/trainEditjg',
        name: '/platform/trainEditjg',
        component: () => import('../views/platform/trainEditjg'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/trainDetailjg',
        name: '/platform/trainDetailjg',
        component: () => import('../views/platform/trainDetailjg'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/education',
        name: '/platform/education',
        component: () => import('../views/platform/education'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/trainEdit',
        name: '/platform/trainEdit',
        component: () => import('../views/platform/trainEdit'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/qydetail',
        name: '/platform/qydetail',
        component: () => import('../views/platform/qyDetail'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/reconciliation',
        name: '/platform/reconciliation',
        component: () => import('../views/platform/reconciliation'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/account',
        name: '/platform/account',
        component: () => import('../views/platform/account'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/match',
        name: '/platform/match',
        component: () => import('../views/platform/match'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/matchDetail',
        name: '/platform/matchDetail',
        component: () => import('../views/platform/matchDetail'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/matchEdit',
        name: '/platform/matchEdit',
        component: () => import('../views/platform/matchEdit'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/courseDetails',
        name: '/platform/courseDetails',
        component: () => import('../views/platform/courseDetails'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/InstitutionalDetails',
        name: '/platform/InstitutionalDetails',
        component: () => import('../views/platform/InstitutionalDetails'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/coachdetail',
        name: '/platform/coachdetail',
        component: () => import('../views/platform/coachdetail'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/institutionsdetail',
        name: '/platform/institutionsdetail',
        component: () => import('../views/platform/institutionsdetail'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/news/list',
        name: '/platform/news/list',
        component: () => import('../views/platform/news/list'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/news/detail',
        name: '/platform/news/detail',
        component: () => import('../views/platform/news/detail'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/news/edit',
        name: '/platform/news/edit',
        component: () => import('../views/platform/news/edit'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/businessAffairsEdit',
        name: '/platform/businessAffairsEdit',
        component: () => import('../views/platform/businessAffairsEdit'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/platform/dict',
        name: '/platform/dict',
        component: () => import('../views/platform/dict'),
        meta: {
            requiresAuth: true
        }
    },

    // {path: '/passwordReset',name: '/passwordReset',component: () => import('../components/nav/ResetPassWord')},

    // {
    // {
    // {
    //   path: '/about',
    //   name: 'about',
    //   // route level code-splitting
    //   // this generates a separate chunk (about.[hash].js) for this route
    //   // which is lazy-loaded when the route is visited.
    //   component: () => import('../views/About.vue')
    // }

    // 教练账号
    {
        path: '/coach/playerDetail',
        name: 'playerDetail',
        component: () => import('../components/coach/PlayerDetail'),
        meta: {
            requiresAuth: true
        }
    },

    // 我的课程
    {
        path: '/coach/wodekecheng',
        name: 'wodekecheng',
        component: () => import('../components/coach/WoDeKeCheng'),
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/coach/onlyReadwodekecheng',
        name: 'onlyReadwodekecheng',
        component: () => import('../components/coach/OnlyReadKeCheng'),
        meta: {
            requiresAuth: true
        }
    }
]

var router = new Router({
    mode: 'hash',
    base: process.env.BASE_URL,
    routes: constantRouterMap
})
router.beforeEach((to, from, next) => {
    if (to.meta.requiresAuth) {
        if (!JSON.parse(sessionStorage.getItem("statusId"))) {
            console.log("需要登录");
            next('/login/login');
        } else {
            console.log("已登录");
            next()
        }
    } else {
        console.log("不需要登录");
        next()
    }

})
export default router
export const asyncRouterMap = [
    {
        path: '/permission',
        // name: 'permissionhome',
        meta: {
            title: 'permission',
            icon: 'el-icon-setting',
            roles: ['admin']
        },
        component: resolve => require(['../views/Home.vue'], resolve),
        children: [
            {
                name: 'permission',
                path: '/permission',
                meta: {
                    title: 'permission', icon: 'el-icon-menu', roles: ['admin']
                },
                component: resolve => require(['../views/Home.vue'], resolve)
            }
        ]
    },
    {path: '*', redirect: '/404', hidden: true}
]
